package com.tuniu.agents.impl.trip.chain;

import com.tuniu.agents.impl.trip.Recommend;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class RecommendHandler extends TripChainHandler {
    private final Recommend tripRecommendAgent;

    public RecommendHandler(Recommend tripRecommendAgent) {
        super("RecommendHandler");
        this.tripRecommendAgent = tripRecommendAgent;
    }

    @Override
    public String handle(String conversationId, String message) {
        try {
            logStart();
            String result = tripRecommendAgent.call(conversationId, message);
            if (result == null || result.isEmpty()) {
                return "Unable to get recommendation information, please try again.";
            }
            logEnd();
            return handleNext(conversationId, result);
        } catch (Exception e) {
            logError(e);
            return "Failed to get recommendation information: " + e.getMessage();
        }
    }
} 